﻿//*********************************************************************************************************************
function isNull(v) {
    return v == null && typeof v == "object";
}
function isUndefined(v) {
    return v == undefined && typeof v == "undefined";
}
function isValid(v) {
    return v != null && v == v && (typeof v != "object" || String(v) != "undefined");
}
function valid(v, v1) {
    if (v == null || v != v || (typeof v == "object" && String(v) == "undefined")) {
        return v1;
    } else {
        return v;
    }
}
function $(v) {
    if (v == null || v != v || (typeof v == "object" && String(v) == "undefined")) {
        switch (typeof v) {
            case "string": return "";
            case "number": return 0;
            case "boolean": return false;
            case "function": return new Function();
            case "undefined": return "";
            case "object": return "";
        }
    } else {
        return v;
    }
}
function $String(v) {
    if (v == null || v != v || (typeof v == "object" && String(v) == "undefined")) {
        return "";
    } else {
        return String(v);
    }
}
function $Number(v) {
    return Number(v) || 0;
}
//*********************************************************************************************************************
function hex(v, w) {
    var v1 = 0, v2 = 0, str = "";
    switch (typeof v) {
        case "string": v = v.charCodeAt(0);
        case "number": v = v || 0; break;
        default: v = 0;
    }
    if (v > 0xfffffffffffff) { return ""; }
    w = parseInt(w);
    str = v.toString(16);
    if (!w) {
        return str;
    } else {
        str = Char("0", Math.abs(w)) + str;
    }
    return str.slice(-w);
}
function octal(v, w) {
    var v1 = 0, v2 = 0, str = "";
    switch (typeof v) {
        case "string": v = v.charCodeAt(0);
        case "number": v = v || 0; break;
        default: v = 0;
    }
    if (v > 0xfffffffffffff) { return ""; }
    w = parseInt(w);
    str = v.toString(8);
    if (!w) {
        return str;
    } else {
        str = Char("0", Math.abs(w)) + str;
    }
    return str.slice(-w);
}
function binary(v, w) {
    var v1 = 0, v2 = 0, str = "";
    switch (typeof v) {
        case "string": v = v.charCodeAt(0);
        case "number": v = v || 0; break;
        default: v = 0;
    }
    if (v > 0xfffffffffffff) { return ""; }
    w = parseInt(w);
    str = v.toString(2);
    if (!w) {
        return str;
    } else {
        str = Char("0", Math.abs(w)) + str;
    }
    return str.slice(-w);
}
//*********************************************************************************************************************
function quoted(s) {
    return "\'" + String(s).replace(/\x27/g, "\'$&") + "\'";
}
function Char(ch, n) {
    if (!String(ch).length) { return ""; }
    ch = String(ch).charAt(0);
    for (var i = 0; i < n; i = ch.length) {
        ch += ch;
    }
    return ch.substr(0, n);
}
function $Blank(s) {
    return String(s).replace(/[\s\n]+/g, " ");
}
function $Decimal(s) {
    return String(s).replace(/[^\d\.]/g, "");
}
function $Numeric(s) {
    return String(s).replace(/[^\d]/g, "");
}
function $Hex(s) {
    return String(s).replace(/[^\dA-Fa-f\.]/g, "");
}
function $Octal(s) {
    return String(s).replace(/[^0-7\.]/g, "");
}
function $Binary(s) {
    return String(s).replace(/[^01\.]/g, "");
}
function $Word(s) {
    return String(s).replace(/[^A-Za-z]/g, "");
}
function $DBCS(s) {
    return String(s).replace(/[\x00-\xFF]/g, "");
}
function $SBCS(s) {
    return String(s).replace(/[^\x00-\xFF]/g, "");
}
function len() {
    return String(s).replace(/[^\x00-\xff]/g, "--").length;
}
function left(s, n) {
    return String(s).substr(0, n);
}
function right(s, n) {
    return String(s).slice(-n);
}
function HTMLEncode(s) {
    s = String(s);
    s = s.replace(/&/g, "&amp;");
    s = s.replace(/</g, "&lt;");
    s = s.replace(/>/g, "&gt;");
    s = s.replace(/ /g, "&nbsp;");
    s = s.replace(/\x22/g, "&quot;");
    return s;
}
function HTMLEncode2(s) {
    var str = "", c; s = String(s);
    for (var i = 0; i < s.length; i++) {
        c = s.charCodeAt(i);
        if (c > 127 || c < 30) {
            str += "&#" + c + ";";
        } else {
            str += s.charAt(i);
        }
    }
    return str;
}
function encode(s) {
    s = String(s).replace(/\\/g, "\\\\");
    s = s.replace(/[\x27\x22]/g, "\\$&");
    s = s.replace(/\n/g, "\\n");
    s = s.replace(/\r/g, "\\r");
    s = s.replace(/\t/g, "\\t");
    s = s.replace(/^/g, "\"");
    s = s.replace(/$/g, "\"");
    return s;
}
function decode(s) {
    s = String(s).replace(/\\\\/g, "\\");
    s = s.replace(/\\n/g, "\n");
    s = s.replace(/\\r/g, "\r");
    s = s.replace(/\\t/g, "\t");
    s = s.replace(/\\f/g, "\f");
    s = s.replace(/\\b/g, "\b");
    s = s.replace(/^([\x27\x22])(.*)\1$/g, "$2");
    return s;
}
function trim(s) {
    return String(s).replace(/(^\s+)|(\s+$)/g, "");
}
function lTrim(s) {
    return String(s).replace(/^\s+/g, "");
}
function rTrim(s) {
    return String(s).replace(/\s+$/g, "");
}
function isNumeric(s) {
    return /^\s*-?\d+(\.\d*)?\s*$/g.test(String(s));
}
function isInt(s) {
    return /^\s*-?\d+\s*$/.test(String(s));
}
function isNegativeInt(v) {
    return /^\s*-\d+\s*$/.test(String(s));
}
function isFloat(s) {
    return /^\s*-?\d+(\.\d+)?\s*$/.test(s);
}
function isNegativeFloat(s) {
    return /^\s*-\d+(\.\d+)?\s*$/.test(String(s));
}
function isEmail(s) {
    return /^[\w\d-_]+(\.[\w\d-_]+)*@[\w\d-_]+(\.[\w\d-_]+)+$/.test(String(s));
}
function isDate(s) {
    var v = parseInt(s);
    if (!isInt(s)) {
        v = String(s).replace(/\/|-|\.|\u5E74|\u6708/g, "/");
        v = v.replace(/\u65F6|\u5206/g, ":");
        v = v.replace(/\u65E5|\u79D2/g, "");
    }
    return !isNaN(Date.parse(v));
}
//*********************************************************************************************************************
function FormatDate(d, t) {

}